package com.herenit.order_model.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import javax.persistence.*;
import java.util.Date;

/**
 *  消费记录
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity(name = "OmRecords")
public class OmRecord {
    /**
     *  主键Id
     */
    @Id
    @SequenceGenerator(name = "records_id_seq", sequenceName = "om_records_id_seq", allocationSize = 1)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "records_id_seq")
    private Long id;

    /**
     *  机构编号
     */
    private String institutionCode;

    /**
     *  医生编号
     */
    private String doctorCode;

    /**
     *  消费状态 1代表消费成功 0代表失败打回
     */
    private int status;

    /**
     *  消息中的字符串
     */
    private String content;

    /**
     *  消费次数 1代表一次处理成功未被打回过 其余表示被失败打回过
     */
    private int count;

    /**
     *  第一次消费的时间戳
     */
    @CreationTimestamp
    @Temporal(value = TemporalType.TIMESTAMP)
    private Date createTime;

    /**
     *  最新消费的时间戳
     */
    @UpdateTimestamp
    @Temporal(value = TemporalType.TIMESTAMP)
    private Date updateTime;

    public OmRecord(String institutionCode, String doctorCode, int status, String content, int count) {
        this.institutionCode = institutionCode;
        this.doctorCode = doctorCode;
        this.status = status;
        this.content = content;
        this.count = count;
    }
}
